﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="App_Resources/jquery-1.7.min.js" type="text/javascript"></script>
    <link href="App_Resources/Site.css" rel="stylesheet" type="text/css" />
    <title></title>
</head>
<body>
    <div class="page">
        <div class="header">
            <div class="title">
                <h1>
                    REST Example
                </h1>
            </div>
        </div>
        <div class="main">
            <form id="form1" runat="server">
            <br />
            Enter some text:
            <input type="text" id="tbMessage" name="tbMessage" />
            <input type="button" onclick="MakeAjaxCall(false); return false;" value="Make Ajax Call" />
            <input type="button" onclick="MakeAjaxCall(true); return false;" value="Make Ajax Call With Server Error" />
            <script type="text/javascript">
                function MakeAjaxCall(throwError) {
                    var data = {};
                    data.clientMessage = $('#tbMessage').val();
                    data.throwError = throwError;

                    $.ajax({
                        url: 'WCFService.svc/SendMessageToServer',
                        data: JSON.stringify(data),
                        type: "POST",
                        processData: false,
                        contentType: "application/json; charset=utf-8",
                        timeout: 300000,
                        dataType: "json",

                        success: function (data, textStatus, jqXHR) {
                            alert(data.d);
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            alert("Error status code: " + jqXHR.status + " - " + jqXHR.statusText);
                        }
                    });
                };
            </script>
            </form>
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="footer">
    </div>
</body>
</html>
